//统一管理咱们项目用户相关的接口
import request from '@/utils/request'
import type {
  LoginFormData,
  LoginResponseData,
  EmailCaptchaData,
  ResponseBaseData,
  ChangePasswordData,
} from './type'
// 项目用户相关的请求地址
enum Auth_API {
  LOGIN_URL = '/system/auth/login', //登录
  GETLOGINCAPTChA_URL = '/system/auth/getCaptcha/', //登录邮箱验证码
  LOGINBYEMAIL_URL = '/system/auth/loginByEmail', //邮箱登录
  CHANGEPASSWORD_URL = '/system/auth/changePassword', //修改密码
  GETCHANGECAPTCHA_URL = '/system/auth/captcha/', //修改邮箱验证码
  LOGOUT_URL = '/system/auth/logout', //注销
}

//登录接口
export const reqLogin = (data: LoginFormData) =>
  request.post<any, LoginResponseData>(Auth_API.LOGIN_URL, data)

export const reqGetLoginCaptcha = (email: string) =>
  request.get<any, ResponseBaseData>(Auth_API.GETLOGINCAPTChA_URL + email)

export const reqLoginByEmail = (data: EmailCaptchaData) =>
  request.post<any, LoginResponseData>(Auth_API.LOGINBYEMAIL_URL, data)

export const reqGetChangeCaptcha = (email: string) =>
  request.get<any, ResponseBaseData>(Auth_API.GETCHANGECAPTCHA_URL + email)

export const reqChangePassword = (data: ChangePasswordData) =>
  request.post<any, ResponseBaseData>(Auth_API.CHANGEPASSWORD_URL, data)

export const reqLogout = () =>
  request.delete<any, ResponseBaseData>(Auth_API.LOGOUT_URL)
